import { DirectiveBinding } from 'vue';

export default {
  mounted(el: HTMLElement, binding: DirectiveBinding) {
    document.addEventListener('click', (_) => {
      if (el.offsetHeight === 0) {
        return;
      }
      binding.value();
    });
  },
  unmounted(el: HTMLElement, binding: DirectiveBinding) {
    el.removeEventListener('click', (_) => {
      if (el.offsetHeight === 0) {
        return;
      }
      binding.value();
    });
  }
};
